<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap-dropdown.js"></script>
	<script type="text/javascript" src="js/bootstrap-modal.js"></script>
	<script type="text/javascript" src="js/bootstrap-transition.js"></script>
	<script type="text/javascript" src="js/bootstrap-alert.js"></script>
	
	<style type="text/css">
		body{
			margin-top:50px;
		}
		.page-header{
			background-color:rgb(240, 245, 248);
		}
		#talk{
			width:570px;
			height:100px;
		}
		
	</style>
	
</head>
<body>
	<div class="navbar navbar-fixed-top">
	  <div class="navbar-inner">
		<div class="container">
			<a class="brand" href="#">
			  <img src="img/user_group.png" alt="" />&nbsp;客户关系管理系统
			</a>
			<ul class="nav">
			  <li class="active">
				<a href="welcome.action">概览</a>
			  </li>
			  <li><a href="contacts.action">通讯录</a></li>
			  <li><a href="tasks.action">任务</a></li>
			  <li><a href="chances.action">机会</a></li>
			  <li><a href="fanhui.action">讨论</a></li>
			  <li class="dropdown" id="menutest1">
				<a class="dropdown-toggle" data-toggle="dropdown" href="#menutest1">
				  添加
				  <b class="caret"></b>
				</a>
				<ul class="dropdown-menu">
				  <li><a href="new_contact.action"><i class="icon-user"></i>&nbsp;联系人</a></li>
				  <li><a href="new_company.action"><i class="icon-home"></i>&nbsp;公司</a></li>
				  <li class="divider"></li>
				  <li><a href="new_task.action"><i class="icon-ok"></i>&nbsp;任务</a></li>
				  <li><a href="new_chance.action"><i class="icon-star-empty"></i>&nbsp;机会</a></li>
				</ul>
			  </li>
			  
			</ul>
			
			<ul class="nav pull-right" >
			  <li>
				<a href="#">${sessionScope.user.username }</a>
			  </li>
			  <li class="dropdown" id="menutest2">
				<a class="dropdown-toggle" data-toggle="dropdown" href="#menutest2">
				  管理
				  <b class="caret"></b>
				</a>
				<ul class="dropdown-menu">
				  <li><a href="manage_user.action?id=${sessionScope.user.id }"><i class="icon-user"></i>&nbsp;同事</a></li>
				  <li><a href="manage_group.action"><i class="icon-list-alt"></i>&nbsp;组</a></li>
				  <li class="divider"></li>
				<!--  <li><a href="user_update_user.action?id=${sessionScope.user.id }"><i class="icon-asterisk"></i>&nbsp;账号</a></li> -->
				  <li><a href="show_user_msg.action?id=${sessionScope.user.id }"><i class="icon-asterisk"></i>&nbsp;账号</a></li>
				</ul>
			  </li>
			  <li class="divider-vertical"></li>
			  <li><a href="sign_in.action">退出</a></li>
			</ul>
			
		</div>
	  </div>
	</div>
	
	<div class="container">
		
			<div class="row">
				  <div class="span2"></div>
				  <div class="span8">
					
						<div class="page-header well">
						  <h2><img src="img/news.png" alt="" />最新动态</h2>
						</div>
							  		<c:if test="${code == '10001' }">
										<div class="alert alert-info  fade in">
										<a class="close" data-dismiss="alert" href="#">&times;</a>
										 		暂无任何动态！！！
										</div>
									</c:if>
						<div class="page-header well">
							
							<table class="table">
							  <tbody>
							  		
							  		
							  		<c:forEach items="${pager.result }" var="message">
									<c:if test="${message.view == 'all' }">
								
									<tr>
									  <td>
									  		${message.content}
									</td>
									<td>
										${message.createtime }
									</td>
									</tr>
									
								</c:if>

								<c:if test="${message.view == 'me' }">
									<c:if test="${message.user.id == sessionScope.user.id }">
										<tr>
										  <td>
										  		${message.content}
										</td>
										<td>
											${message.createtime }
										</td>
										</tr>
									</c:if>
								</c:if>
								
								<c:if test="${userGroup.groupname == message.view }">
									<tr>
										  <td>
										  		${message.content}
										</td>
										<td>
											${message.createtime }
										</td>
										</tr>
								</c:if>
							
								
								</c:forEach>
									
									
								
							  </tbody>
							</table>
							
							
						</div>		
						
						<Script Language="JavaScript" type="text/JavaScript" src="js/showo_page.js"></Script>
					          
					<%-- 效果2:记录总数${pager.totalCount},每页${pager.pageSize}记录,前后显示4个<br>&nbsp;&nbsp;&nbsp; --%>
					<Script Language=JavaScript>
					   ShowoPage("","","<span style='margin-left:80px;'>页次:</span><font color='red'>","</font>/","<font color='red'>","</font>页&nbsp;","&nbsp;每页<font color='red'>","</font>条&nbsp;","&nbsp;共<font color='red'>","</font>个记录&nbsp;&nbsp;","首页","上一页","下一页","尾页","&nbsp;&nbsp;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style='margin-left:150px;'>跳转</span>:","<font color='red'>","</font>","[<font color='red'>","</font>]","","","&nbsp;","&nbsp;","${pager.totalCount}","${pager.pageSize}",3)
					</Script> 	
						
				  </div>
				  <div class="span4">
						<!-- <div class="page-header well">
						  <h3>最近访问的同事</h3>
							<table class="table">
							  <tbody>
								<tr>
								  <td><img src="img/contact.png" alt="" /><a href="">同事1</a></td>
								</tr>
								<tr>
								  <td><img src="img/contact.png" alt="" /><a href="">同事2</a></td>
								</tr>
								<tr>
								  <td><img src="img/contact.png" alt="" /><a href="">同事3</a></td>
								</tr>
							  </tbody>
							</table>
						</div> -->	
						
						<div class="page-header well">
						  <h3>
							<span>
							<a data-backdrop="static" href=".modal" data-toggle="modal"><img src="img/add_task.png" alt="" />添加任务</a>
							</span>
						  </h3>
							<div class="modal fade" id="myModal">
							  <div class="modal-header">
								<a class="close" data-dismiss="modal">×</a>
								<h3>对话框标题</h3>
							  </div>
							  <div class="modal-body">
								<p>对话框内容</p>
							  </div>
							  <div class="modal-footer">
								<a href="#" class="btn">关闭</a>
								<a href="#" class="btn btn-primary">保存更新</a>
							  </div>
							</div>
						</div>	
						<div class="page-header well">	
						  <h3>您的待办任务 </h3>
							<table class="table">
							  <tbody  id="ts">
							  <c:forEach items="${ listtasks}" var="task">
								<tr>
								  <td>
								  <input type="checkbox" name="dfh"  id="${task.taskuuid}" res="${task.id}">
								  <span style="background-color:#${task.taskType.color}">${task.taskType.type}</span>
								  <a href="">${task.title}</a>
								  <br>
								  <span>${task.createtime}</span>
								  
								  </td>
								</tr>
								</c:forEach>
								
								
								<!-- <tr>
								  <td><img src="img/task.png" alt="" /><a href="">任务2</a></td>
								</tr>
								<tr>
								  <td><img src="img/task.png" alt="" /><a href="">任务3</a></td>
								</tr> -->
							  </tbody>
							</table>
						</div>	
				  </div>
				</div>
			</div>
	
		</div>
		
	<script type="text/javascript">
		$(document).ready(function(){
			
			$(".alert").alert();
		
			$("#new_task").click(function(){
				$('#myModal').modal({
					backdrop:true,
					keyboard:true,
					show:false
				});
			});
			  $("input").click(function(){
		      var taskid= $(this).attr("res");
		      var id= $(this).attr("id");
		      //alert(id);
		      var h="#"+id;
		      var check=$(this).attr("checked");
		      //alert(check);
		      if(check=="checked"){
		        if(confirm("确定要删除吗？")){
		          $.post("dealTask.action",{taskid:taskid},function(json){
		       
		        });
		            $(h).ajaxComplete(function(){
		              //  alert("fdf");
		               deltelim(this);
		    
		 });
		    
		        
		        }else{
		          $(this).attr("checked",false);
		        
		        }}
			
			
			
			
		});
		});
			 function deltelim(obj) {
			var div =  obj.parentNode.parentNode;
			document.getElementById("ts").removeChild(div);
  }
		
	</script>
</body>
</html>